<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">

    var book = {
        year: 2020,
        edition: 1
    }
    Object.defineProperty(book, 'date', {
        get() {
            return this.year - 10
        },
        set(v) {
            if (v < 2020) {
                this.year = v
                this.edition = 2020 - v
            }
        }
    })
    book.date = 2018
    console.log(book)

</script>

</body>
</html>
